/*******************************************************************************
 * This file is part of blueprint4j www.blueprint4j.org.
 * 
 *     blueprint4j is free software: you can redistribute it and/or modify
 *     it under the terms of the GNU Lesser General Public License as published by
 *     the Free Software Foundation, either version 3 of the License, or
 *     (at your option) any later version.
 * 
 *     blueprint4j is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU Lesser General Public License for more details.
 * 
 *     You should have received a copy of the GNU Lesser General Public License
 *     along with blueprint4j. If not, see <http://www.gnu.org/licenses/>.
 ******************************************************************************/
package blueprint4j.utils;

import java.io.*;
import java.text.*;
import java.util.*;
import javax.swing.*;

public class LoggingSystemOut extends Logging {
	public static JFrame parent = null;

	SimpleDateFormat date_format=new SimpleDateFormat("yyyy-MM-dd 'at' HH'h'mm.ss");

	public LoggingSystemOut(boolean debug, boolean trace, boolean critical) {
		super(debug, trace, critical);
	}

	public LoggingSystemOut(boolean debug, boolean dev,boolean trace, boolean critical) {
		super(debug, dev, trace, critical,false);
	}
	
	public LoggingSystemOut(boolean debug, boolean dev,boolean trace, boolean critical,boolean message) {
		super(debug, dev, trace, critical,true,message);
	}

	public void write(String level,long thread_id,String description, String details) {
		if ("Message".equals(level)) {
			//JOptionPane.showMessageDialog(parent,details,description,JOptionPane.INFORMATION_MESSAGE);
			Utils.createDialog(parent,description,details,false).setVisible(true);
		}
		System.out.println(
		   level+" ["+thread_id+"] " + date_format.format(new Date()) + "\n" +
		   "TCE " + date_format.format(new Date()) + "\n" +
		   "Description: " + description + "\n" +
		   details + "\n" +
		   "-------------------------------------"
		);
		if (Logging.CRITICAL.toString().equals(level)) {
			new Exception("CURRENT STACK TRACE").printStackTrace();
		}
	}
	/*
		public void writeDebug(String description, String details){
			System.out.println(
				"DBG " + date_format.format(new Date()) + "\n" +
				"Description: " + description + "\n" +
				details + "\n" +
				"-------------------------------------"
			);
		}

		public void writeCritical(String description, String details){
			System.out.println(
				"CRT *** " + date_format.format(new Date()) + "\n" +
				"Description: " + description + "\n" +
				details + "\n" +
				"-------------------------------------"
			);
		}*/

	public LogDataUnitVector findLogs(Integer tid,java.util.Date from_date,java.util.Date to_date,Logging.Level levels[])
	throws IOException {
		return new LogDataUnitVector();
	}
}

